package impl;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;

public class SelectionSorter extends AbstractSorter {

    public SelectionSorter() {
        super(SorterType.SELECTION);
    }

    public <T> void sort(Comparator<T> comparator, List<T> list) {
        for (int i = 0; i < list.size(); i++) {
            int menor = i;
            for (int j = i + 1; j < list.size(); j++) {
                if (greater(comparator,list,menor,j)) {
                    menor = j;
                }
            }
            swap(list, i, menor);
        }
    }
}
